package aash.catalog.views.button;

import aash.catalog.views.panel.PropertyPanel;

/**
 * RoundButton for Explorer View.
 * @author Aashintan
 */
public class PropertyButton extends RoundButton {
    /**
     * serialVersionUID.
     */
    private static final long serialVersionUID = -7014919193969768154L;
    /**
     * Default margin X.
     */
    private final int defaultMarginX = 10;
    /**
     * Margin X.
     */
    private int marginX;

    /**
     * Class constructor.
     * @param pp property panel
     * @param stType of the button
     */
    public PropertyButton(final PropertyPanel pp, final String stType) {
        super(stType);
        marginX = defaultMarginX;
        int xPos;
        if (stType.contains("left")) {
            xPos = pp.getX() - getRadius() - defaultMarginX;
        } else {
            xPos = pp.getX() + pp.getWidth() + defaultMarginX;
        }
        int yPos = pp.getY() + (int) ((((double) pp.getHeight()) / 2) - (((double) getRadius()) / 2));
        setBounds(xPos, yPos);
    }

    /**
     * Set the X-axis margin.
     * @param iMarginX to set
     */
    public final void setMarginX(final int iMarginX) {
        int xPos = getX() - marginX + iMarginX;
        setX(xPos);
        marginX = iMarginX;
    }
}
